<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no" />
	<title>title</title>
	<link rel="stylesheet" type="text/css" href="../css/api.css"/>
	<style>
		html, body {
			background-color: #f8f8f8;
		}
		.map_box {
			position: relative;
			box-shadow: 0px -2px 10px #999;
			height: 260px;
		}
		.map_box .back {
			width: 28px;
			position: absolute;
			left: 15px;
			top: 35px;
		}
		.state_p {
			height: 60px;
			line-height: 60px;
			color: #333;
			font-size: 17px;
			text-align: center;
			background-color: #fff;
			margin-bottom: 6px;
		}
		.staff_phone {
			height: 65px;
			background-color: #fff;
			border-bottom: 1px solid #e8e8e8;
			overflow: hidden;
		}
		.staff_phone .staff_phonel {
			height: 65px;
			float: left;
			display: -webkit-box;
			-webkit-box-align: center;
			padding: 0 15px;
		}
		.staff_phone .staff_phonel .img_box {
			width: 40px;
			height: 40px;
			border-radius: 50%;
			overflow: hidden;
			border: 1px solid #d3d3d3;
		}
		.staff_phone .staff_phonel .img_box img {
			width: 100%;
			height: 100%;
			object-fit: cover;
		}
		.staff_phone .staff_phoner {
			height: 65px;
			float: right;
			padding: 0 15px;
			display: -webkit-box;
			-webkit-box-align: center;
		}
		.staff_phone .staff_phoner img {
			width: 36px;
			display: block;
		}
		.order_complete {
			background-color: #fff;
			text-align: center;
			padding: 15px 0;
			margin-bottom: 6px;
		}
		.order_complete img {
			height: 36px;
			vertical-align: middle;
		}
		.order_complete .order_p {
			font-size: 15px;
			font-weight: bold;
			color: #333;
			margin-top: 11px;
		}
		.order_complete .order_btn {
			margin-top: 20px;
			overflow: hidden;
			display: inline-block;
		}
		.order_complete .order_btn .btn {
			width: 70px;
			height: 26px;
			line-height: 26px;
			float: left;
			color: #e62442;
			border: 1px solid #e62442;
			border-radius: 5px;
			margin-right: 10px;
			font-size: 12px;
		}
		.order_complete .order_btn .btn:last-child {
			margin-right: 0;
		}
		.order_complete .order_btn .btn_s {
			color: #fff;
			background-color: #e62442;
		}
		.seller_info {
			display: -webkit-box;
			display: -webkit-flex;
			align-items: center;
			background-color: #fff;
			padding: 10px 15px;
			border-bottom: 1px solid #e8e8e8;
		}
		.seller_info .seller_info_l .seller_img {
			width: 45px;
			height: 45px;
		}
		.seller_info .seller_info_l .seller_img img {
			width: 100%;
			height: 100%;
			object-fit: cover;
		}
		.seller_info .seller_info_c {
			width: 0;
			flex: 1;
			-webkit-flex: 1;
			box-flex: 1;
			-webkit-box-flex: 1;
			padding: 0 10px;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
		}
		.seller_info .seller_info_r img {
			height: 13px;
			display: block;
		}
		.order_info {
			background-color: #fff;
			margin-bottom: 6px;
		}
		.order_info .goods {
			padding: 16px 15px;
			border-bottom: 1px solid #e8e8e8;
			display: -webkit-box;
			display: -webkit-flex;
			color: #999;
		}
		.order_info .goods .goods_l {
			width: 0;
			box-flex:1;
			-webkit-box-flex:1; 
			flex:1;
			-webkit-flex:1; 
		}
		.order_info .goods ul li {
			margin-bottom: 19px;
		}
		.order_info .goods ul li:last-child .li_box {
			margin-bottom: 0;
		}
		.order_info .goods .li_boxl {
			font-size: 14px;
			flex: 1;
			-webkit-flex: 1;
			box-flex: 1;
			-webkit-box-flex: 1;
			padding-right: 5px;
		}
		.order_info .goods .li_boxr {
			font-size: 12px;
			overflow: hidden;
		}
		.order_info .goods .li_boxr .goods_num {
			margin-right: 17px;
			float: left;
		}
		.order_info .goods .li_boxr .goods_price {
			float: right;
		}
		.discount_box {
			border-bottom: 1px solid #e8e8e8;
		}
		.discount {
			height: 50px;
			line-height: 50px;
			padding: 0 15px;
			display: -webkit-box;
			display: -webkit-flex;
		}
		.discount .discount_l {
			font-size: 12px;
			color: #999;
			flex: 1;
			-webkit-flex: 1;
			box-flex: 1;
			-webkit-box-flex: 1;
		}
		.discount .discount_l span {
			width: 16px;
			height: 16px;
			line-height: 16px;
			text-align: center;
			background-color: #ff5f78;
			color: #fff;
			display: inline-block;
			border-radius: 3px;
			margin-right: 5px;
		}
		.discount .discount_r {
			color: #999;
			font-size: 12px;
		}
		.distribution_price {
			height: 50px;
			line-height: 50px;
			padding: 0 15px;
			display: -webkit-box;
			display: -webkit-flex;
			border-bottom: 1px solid #e8e8e8;
		}
		.distribution_price .distribution_price_l {
			color: #333;
			font-size: 15px;
			flex: 1;
			-webkit-flex: 1;
			box-flex: 1;
			-webkit-box-flex: 1;
		}
		.distribution_price .distribution_price_r {
			color: #999;
			font-size: 12px;
		}
		.common_box {
			height: 50px;
			line-height: 50px;
			padding: 0 15px;
			display: -webkit-box;
			display: -webkit-flex;
			border-bottom: 1px solid #e8e8e8;
			background-color: #fff;
		}
		.common_box .common_boxl {
			color: #333;
			font-size: 15px;
			padding-right: 5px;
		}
		.common_box .common_boxr {
			flex: 1;
			-webkit-flex: 1;
			box-flex: 1;
			-webkit-box-flex: 1;
			color: #999;
			font-size: 12px;
			text-align: right;
		}
		.common_box .gst_num {
			color: #999;
		}
		.no_border_bottom {
			border-bottom: none;
		}
		.price_num {
			color: #e62442;
			font-size: 15px;
		}
		.remark_box {
			background-color: #fff;
		}
		.remark_box textarea {
			width: 100%;
			height: 60px;
			color: #999;
			font-size: 14px;
			padding: 10px 15px;
			box-sizing: border-box;
			display: block;
		}
		.remark_box textarea::-webkit-input-placeholder {
			color: #999;
		}
		.title_p {
			height: 35px;
			line-height: 41px;
			padding: 0 15px;
			font-size: 12px;
			color: #999;
		}
		.distribution_box {
			padding: 14px 15px;
			display: -webkit-box;
			display: -webkit-flex;
			align-items: center;
			border-bottom: 1px solid #e8e8e8;
			background-color: #fff;
		}
		.distribution_box .distribution_boxl {
			color: #333;
			font-size: 15px;
			padding-right: 5px;
		}
		.distribution_box .distribution_boxr {
			flex: 1;
			-webkit-flex: 1;
			box-flex: 1;
			-webkit-box-flex: 1;
			color: #999;
			font-size: 12px;
			text-align: right;
		}
		.distribution_box .distribution_boxr .distribution_p1 {
			margin-bottom: 10px;
		}
        .staff_box {
            padding: 14px 15px;
            display: -webkit-box;
            display: -webkit-flex;
            align-items: center;
            background-color: #fff;

        }
        .staff_box .staff_boxl {
            flex: 1;
            -webkit-flex: 1;
            box-flex: 1;
            -webkit-box-flex: 1;
            color: #333;
            font-size: 15px;
            padding-right: 5px;
        }
        .staff_box .staff_boxc {
            margin-right: 7px;
        }
        .staff_box .staff_boxc .staff_img {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            overflow: hidden;
            border: 1px solid #d3d3d3;
        }
        .staff_box .staff_boxc .staff_img img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        .staff_box .staff_boxr {
            color: #999;
            font-size: 12px;
        }
        .staff_box .staff_boxr .staff_p1 {
            margin-bottom: 10px;
        }
		.hidden {
			display: none !important;
		}
		.h10 {
			height: 10px;
		}
		.remark_box {
			background-color: #fff;
		}
		.remark_box .remark_detail {
			width: 100%;
			/*height: 60px;*/
			color: #333;
			font-size: 14px;
			padding: 10px 15px;
			box-sizing: border-box;
			display: block;
		}
		.remark_box .remark_detail .remark_desc{
			color: #999;
		}
	</style>
</head>
<body>
	<div class="map_box">
		<!-- <img style="width: 100%; vertical-align: middle;" src="../image/temp/map.png"> -->
		<!-- <img class="back" tapmode onclick="api.closeWin();" src="../image/back2.png"> -->
	</div>
	<div class="state_p status_desc"></div>
	<div class="staff_phone hidden">
		<div class="staff_phonel">
			<div class="img_box">
				<img class="staff_head" src="../image/default.png">
			</div>
		</div>
		<div class="staff_phoner" onclick="fnCallStaff();" tapmode>
			<img src="../image/seller_icon5.png">
		</div>
	</div>

    <div class="order_info">
        <div class="goods" id="goods_ul">
       <!--      <div class="goods_l">
                <ul >
                    <li>
                        <div class="li_boxl">菜品名称</div>
                    </li>
                    <li>
                        <div class="li_boxl">餐盒</div>
                    </li>
                </ul>
            </div>
            <div class="goods_r">
                <ul>
                    <li>
                        <div class="li_boxr">
                            <span class="goods_num">×1</span>
                            <span class="goods_price">RM19</span>
                        </div>
                    </li>
                    <li>
                        <div class="li_boxr">
                            <span class="goods_num">×33</span>
                            <span class="goods_price">RM3</span>
                        </div>
                    </li>
                </ul>
            </div> -->
        </div>
        <div class="discount_box">
            <ul>
                <li>
                    <div class="discount">
                        <div class="discount_l"><span>减</span><time class="coupon_str">满减</time></div>
                        <div class="discount_r">-RM<span class="coupon">0.00</span></div>
                    </div>
                </li>
                <li>
                    <div class="discount">
                        <div class="discount_l"><span >卷</span>使用优惠卷</div>
                        <div class="discount_r">-RM<span class="ticket">0.00</span></div>
                    </div>
                </li>
            </ul>
        </div>
        <div class="common_box">
            <div class="common_boxl">配送费</div>
            <div class="common_boxr">RM<span class="delivery_price"></span></div>
        </div>
        <div class="common_box gst_box">
            <div class="common_boxl">GST<span class="gst_num">（6.00%）</span></div>
            <div class="common_boxr">RM<span class="gst_fee"></span></div>
        </div>
        <div class="common_box no_border_bottom">
            <div class="common_boxl">订单金额</div>
            <div class="common_boxr price_num">RM<span class="must_pay"></span></div>
        </div>
    </div>
<!--     <div class="remark_box">
        <textarea placeholder="请输入文字"></textarea>
    </div> -->
    <div class="remark_box">
        <div class="remark_detail"><span class="remark_desc"></span></div>
    </div>
    <div class="title_p">配送信息</div>
    <div class="distribution_box">
        <div class="distribution_boxl">收货地址</div>
        <div class="distribution_boxr">
            <div class="distribution_p1 address_detail"></div>
            <div class="distribution_p2"><span class="username"></span> <span class="tel"></span></div>
        </div>
    </div>
    <div class="staff_box hidden">
        <div class="staff_boxl">骑手信息</div>
        <div class="staff_boxc">
            <div class="staff_img">
                <img class="staff_head" src="../image/default.png">
            </div>
        </div>
        <div class="staff_boxr">
            <div class="staff_p1 staff_name"></div>
            <div class="staff_p2 staff_tel"></div>
        </div>
    </div>
    <div class="title_p">订单信息</div>
    <div class="common_box">
        <div class="common_boxl">订单号</div>
        <div class="common_boxr order_number"></div>
    </div>
    <div class="common_box">
        <div class="common_boxl">支付方式</div>
        <div class="common_boxr">在线支付</div>
    </div>
    <div class="common_box no_border_bottom">
        <div class="common_boxl">下单时间</div>
        <div class="common_boxr create_time"></div>
    </div>
    <div class="h10"></div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script id="goodsTpl" type="text/x-dot-template">
    <div class="goods_l">
        <ul >
            {{ for(var i=0;i<it['goods'].length;i++){ }}
                <li>
                    <div class="li_boxl">{{=it['goods'][i]['goods_name']}}</div>
                </li>
            {{ }; }}
            <li>
                <div class="li_boxl">餐盒</div>
            </li>
        </ul>
    </div>
    <div class="goods_r">
        <ul>
            {{ for(var i=0;i<it['goods'].length;i++){ }}
                <li>
                    <div class="li_boxr">
                        <span class="goods_num">×{{=it['goods'][i]['goods_num']}}</span>
                        <span class="goods_price">RM{{=(it['goods'][i]['price']*it['goods'][i]['goods_num']).toFixed(2)}}</span>
                    </div>
                </li>
            {{ }; }}
            <li>
                <div class="li_boxr">
                    <span class="goods_num">×{{=it['canteen_num']}}</span>
                    <span class="goods_price">RM{{=(it['canteen_price']*1).toFixed(2)}}</span>
                </div>
            </li>
        </ul>
    </div>
</script>
<script type="text/javascript">
	apiready = function(){
		openLoading();
		id = api.pageParam.id;
        status = api.pageParam.status;
        user = $api.getStorage('shop_data');
        getOrder();

	};

	function getOrder() {
        user = $api.getStorage('shop_data');
        api.ajax({
            url: rootPath+'/api/seller_order/order_detail',
            method: 'get',
            data: {
                values: { 
                    order_id: id,
                    shop_id:user.id,
                    token:user.token
                },

            }
        }, function(ret, err) {
            if (ret) {
            	if(ret.data.status == 3) {
            		$('.status_desc').text('骑手已抢单，正在赶来取餐');
            		$('.staff_phone').removeClass('hidden');
            		$('.staff_box').removeClass('hidden');
            		fnOpenMap(ret.data.shop_lng,ret.data.shop_lat,ret.data.staff.lng,ret.data.staff.lat,'seller_icon3.png');
            	}else if(ret.data.status == 4) {
            		$('.status_desc').text('骑手已取餐，正在配送中');
            		$('.staff_phone').removeClass('hidden');
            		$('.staff_box').removeClass('hidden');
            		fnOpenMap(ret.data.shop_lng,ret.data.shop_lat,ret.data.staff.lng,ret.data.staff.lat,'seller_icon3.png');
            	}
            	if(ret.data.staff) {
            		var staff_img = formatHeadImg(ret.data.staff.img);
            		$('.staff_head').attr('src',staff_img);
            		$('.staff_name').text(ret.data.staff.username);
            		$('.staff_tel').text(ret.data.staff.phone);
            		staff_phone = ret.data.staff.phone;
            	}
                shop_id = ret.data.shop_id;
                setDotData(ret.data,'goodsTpl','goods_ul',true);
                $('.shop_title').text(ret.data.shop_name);
                var shop_img = formatHeadImg(ret.data.shop_img);
                $('.shop_img').attr('src',shop_img);
                if(ret.data.gst_fee > 0) {
                  $('.gst_box').css('display','-webkit-flex');
                  $('.gst_fee').text(parseFloat(ret.data.gst_fee).toFixed(2));
                }else{
                	$('.gst_box').css('display','-webkit-flex');
                  	$('.gst_fee').text('0.00');
                }
                $('.delivery_price').text(ret.data.delivery_price);
                $('.must_pay').text(ret.data.must_pay);
                $('.address_detail').text(ret.data.address_detail);
                $('.username').text(ret.data.username);
                $('.tel').text(ret.data.tel);
                $('.order_number').text(ret.data.order_number);
                $('.create_time').text(ret.data.create_time);
                if(ret.data.coupon) {
                	$('.coupon_str').text(ret.data.coupon_str);
                	$('.coupon').text(parseFloat(ret.data.coupon.reduce_price).toFixed(2));
                }else{
                    $('.coupon').text('0.00');
                }
                if(ret.data.ticket){
                	$('.ticket').text(parseFloat(ret.data.ticket.price).toFixed(2));
                }else{
                    $('.ticket').text('0.00');
                }
                var _remark = ret.data.remark?ret.data.remark:'暂无备注';
                $(".remark_desc").text(_remark);
            } else {
                alert(JSON.stringify(err.msg));
            }
            closeLoading();
        });
    }

    function fnOpenShop() {
        if(shop_id) {
            api.openWin({
                name: 'seller',
                url: './seller.html',
                pageParam: {
                    id: shop_id
                }
            });
        }
    }

    function fnOpenMap(center_lon,center_lat,an_lon,an_lat,an_img) {
    	var GoogleMap = api.require('googleMap');
		GoogleMap.open({
		    rect: {
		        x: 0,
		        y: 0,
		        w: 'auto',
		        h: 260
		    },
		    center: {
		        lon: center_lon,
		        lat: center_lat
		    },
		    zoomLevel: 16,
		    showUserLocation: false,
		    fixedOn: api.frameName,
		    fixed: false
		 }, function(ret) {
		    if (ret.status) {
		    	//标注头像
		        GoogleMap.addAnnotations({
				    annotations: [{
				        id: 1,
				        lon: an_lon,
				        lat: an_lat
				    }],
				    icon: 'widget://image/'+an_img,
				    draggable: true
				}, function(ret) {
				    if (ret) {
				        
				    }
				});
		    }
		 });
		api.openFrame({
		    name: 'back_frame',
		    url: 'back_frame.html',
		    rect: {
		        x: 20,
		        y: 30,
		        w: 50,
		        h: 50
		    },
		    bgColor:'rgba(0,0,0,0)'

		});
    }

    function fnCallStaff() {
    	if(staff_phone) {
	    	api.call({
			    type: 'tel_prompt',
			    number: '+'+staff_phone
			});
    	}
    }
</script>
</html>